/*    
 * Copyright (c) 2013 ISoftStone, Inc.
 * All right reserved.
 *
 * 文件名：      IChargingItemDetailDao.java
 * 作者:     Jacky Wang
 * 创建日期： 2013-7-25 下午03:23:36
 * 版本：           
 *
 */
package com.isoftstone.industry.aaa.core.dao.assist;

import java.sql.Timestamp;
import java.util.Date;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.isoftstone.industry.persistance.bean.ChargingItemDetail;
import com.isoftstone.modules.core.persistence.IGenericDao;

/**
 * @author jacky
 */
public interface ChargingItemDetailDao extends IGenericDao<ChargingItemDetail, String>
{
	@Modifying
	@Query("update ChargingItemDetail d set d.status = :status, d.statusTime= :modified where d.id = :id")
	void changeStatus(@Param("id") String id, @Param("status") String status, @Param("modified") Timestamp modified);

	@Modifying
	@Query("update ChargingItemDetail d set d.lastChargingTime=:modifiedTime, d.chargingEndDate=:endDate where d.id=:id")
	void changeLastChargingTimeAndChargingEndDate(@Param("id") String id, @Param("modifiedTime") Timestamp modifiedTime, @Param("endDate") Date endDate);
	
	@Modifying
	@Query("update ChargingItemDetail d set d.lastChargingTime=:modifiedTime where d.id=:id")
	void changeLastChargingTime(@Param("id") String id, @Param("modifiedTime") Timestamp modifiedTime);
	
	@Modifying
	@Query("update ChargingItemDetail d set d.status = :status, d.statusTime= :modified where d.chargingItem.id = :parentId")
	void changeStatusByParent(@Param("parentId") String parentId, @Param("status") String status, @Param("modified") Timestamp modified);
}
